import { ChartFormContext } from '@/ChartForm';
import { EChartType, ESubChartType } from '@/core/ChartType';
import AriesFormFactory from './AriesFormFactory';
import AxisFormFactory from "./AxisFormFactory";
import PieFormFactory from "./PieFormFactory";
import RadarFormFactory from "./RadarFormFactory";

export default function getFormFactoryProvider(chartType: EChartType) {
    let subChartType: ESubChartType | EChartType;
    const factorys: { [key: number]: (subChartType?: ESubChartType) => ChartFormContext } = {
        [EChartType.AxisChart]: AxisFormFactory,
        [EChartType.PieChart]: PieFormFactory,
        [EChartType.RadarChart]: RadarFormFactory,
        [EChartType.AriesChart]: AriesFormFactory
    }
    function getFormContext(
        _subChartType?: number
    ) {
        const currentFactory = factorys[chartType]
        return currentFactory(_subChartType);
    }
    return {
        factory: getFormContext
    }
}